package com.tadpole.music.view.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.config.Constant;
import com.tadpole.music.utils.Mutils;
import com.tadpole.music.utils.NoDoubleClickListener;
import com.tadpole.music.utils.SpUtil;
import com.tadpole.music.utils.ToastUtils;
import com.tadpole.music.view.activity.base.BaseActivity;
import com.tadpole.music.view.activity.login.LoginActivity;

/**
 * 意见反馈
 * Created By 孙岩
 * on 2021/5/26
 */
public class FanKuiActivity extends BaseActivity {
    //回退
    private View view_back_icon;
    //标题
    private TextView actionbar_title;
    //反馈内容
    private EditText etText;
    //提交
    private TextView tvSubmit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fankui);
        initViews();
        initListeners();
    }

    //初始化控件
    private void initViews(){
        view_back_icon = findViewById(R.id.view_back_icon);
        actionbar_title = findViewById(R.id.actionbar_title);
        actionbar_title.setText("意见反馈");
        etText = findViewById(R.id.etText);
        tvSubmit = findViewById(R.id.tvSubmit);
    }

    //初始化监听器
    private void initListeners(){
        view_back_icon.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                FanKuiActivity.this.finish();
            }
        });

        tvSubmit.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                if(Mutils.isNetworkAvailable()){
                    if(SpUtil.getInstance(FanKuiActivity.this).getString(Constant.TOKEN,"").equals("")){
                        Intent intent = new Intent(FanKuiActivity.this, LoginActivity.class);
                        startActivity(intent);
                    }else{
                        if(etText.getText().toString().trim().equals("")){
                            ToastUtils.show("请输入您的宝贵意见");
                        }else{
                            ToastUtils.show("提交成功");
                            FanKuiActivity.this.finish();
                        }

                    }
                }else{
                    ToastUtils.show(getResources().getString(R.string.net_work));
                }
            }
        });
    }
}
